package com.elinshaw.pattern.bus;

import java.lang.reflect.Method;

/**
 * @author Administrator
 */
public class BasicEventContext implements EventContext {

    private final String eventBusName;

    private final Subscriber subscriber;

    private final Object event;

    public BasicEventContext(String eventBusName, Subscriber subscriber, Object event) {
        this.eventBusName = eventBusName;
        this.subscriber = subscriber;
        this.event = event;
    }

    @Override
    public String getSource() {
        return this.eventBusName;
    }

    @Override
    public Object getEvent() {
        return this.event;
    }

    @Override
    public Method getSubscribe() {
        return subscriber != null ? subscriber.getSubscriberMethod() : null;

    }

    @Override
    public Object getSubscriber() {
        return subscriber != null ? subscriber.getSubscriberObject() : null;
    }

}
